package com.yshkj.payment.repository.builder;

import com.yshkj.payment.entity.Demo;
import org.springframework.data.jpa.domain.Specification;
import org.springframework.stereotype.Repository;

import javax.persistence.criteria.CriteriaBuilder;
import javax.persistence.criteria.CriteriaQuery;
import javax.persistence.criteria.Predicate;
import javax.persistence.criteria.Root;
import java.util.Map;

/**
 * 构建查询条件
 * Created by 唐旭 on 2016/8/25.
 */
@Repository
public class DemoSpecificationBuilder {
    public Specification<Demo> list(Map<String, Object> query) {
        return new Specification<Demo>() {
            @Override
            public Predicate toPredicate(Root<Demo> root, CriteriaQuery<?> criteriaQuery, CriteriaBuilder criteriaBuilder) {
                //build your query parameter
                return criteriaBuilder.conjunction();
            }
        };
    }
}
